package javaDemo07;

import java.io.*;

public class Recursion {
    public static void main(String[] args) throws IOException {

    }


    public static int getCharUp(char[] chars) {
        return getCharUp(chars, chars.length-1);
    }

    /** 返回数组中大写字母的个数辅助方法 */
    public static int getCharUp(char[] chars, int high) {
        int v = Character.isUpperCase(chars[high]) ? 1 : 0;
        return high == 0 ? v : (v + getCharUp(chars, high-1));
    }


    public static int gcd(int a,int b){
        if(a % b == 0){
            return b;
        }else{
            return gcd(b,a % b);
        }
    }

    public static void reversInt(int value){
        if(value < 10){
            System.out.print(value);
        }else{
            reversInt(value % 10);
            reversInt(value / 10);
        }

    }

    public static void reversString(String value){
        char[] cha = value.toCharArray();
        if(cha.length == 1){
            System.out.print(cha[0]);
        }else{
            reversString(String.valueOf(cha[cha.length - 1]));
            reversString(String.valueOf(cha,0,cha.length - 1));
        }
    }

    public static int count(String str,char a){
        char[] cha = str.toCharArray();
        int sum = 0;
        if(cha.length == 1){
            if(cha[0] == a){
                return ++sum;
            }else{
                return sum;
            }
        }else{
            return count(String.valueOf(cha[cha.length - 1]),a) + count(String.valueOf(cha,0,cha.length - 1),a);
        }

    }

    public static void reversString(String value,int high){
        char[] cha = value.toCharArray();
        if(high == 1){
            System.out.print(cha[0]);
        }else{
            reversString(String.valueOf(cha[high - 1]),1);
            reversString(String.valueOf(cha,0,high - 1),high - 1);
        }
    }

    public static int getMax(int[] arr,int max){
        int length = arr.length - max;
        if(length == 1){
            return arr[max];
        }else{
            return Math.max(arr[max],getMax(arr,max + 1));
        }
    }

    public static int getUp(String a){
        char[] cha = a.toCharArray();
        if(cha.length == 1){
            if(Character.isUpperCase(cha[0])){
                return 1;
            }else{
                return 0;
            }
        }else{
            return getUp(String.valueOf(cha[0])) + getUp(String.valueOf(cha,1,cha.length - 1));
        }
    }

}
